# -*- coding: utf-8 -*-


class BaseConfig:
    SECRET_KEY = '6943652fc24133ba6418414ea459736c866a5aebd8b85bd4'
    SERIALIZER_SALT = 'TLAS EMOS'


class DevelopmentConfig(BaseConfig):
    DEBUG = True
    # SERVER_NAME = '127.0.0.1:8080'
    # SERVER_NAME = 'www.guanjia.group'

    SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://root:feibonaqi2017!@127.0.0.1:3333/guanjia?charset=utf8mb4'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_ECHO = False

    WTF_CSRF_CHECK_DEFAULT = False
    WTF_CSRF_FIELD_NAME = 'form_token'
    WTF_CSRF_HEADERS = ['X-FormToken', 'X-Form-Token']

    INSTALLED_BLUEPRINTS = [
        'gzone:gzone',
        'upload:upload',
    ]
    LOGGER_TARGETS = [
        'sqlalchemy',
        'flask_wtf.csrf',
        'gzone',
    ]
    LOGGER_LEVELS = ['DEBUG', 'WARNING']
    # LOGGER_ENCODING = 'utf-8'
    # LOGGER_FILE_PATH = '/path/to/log/file/'
    # LOGGER_FILE_PREFIX = 'gzone'

    # -- gzone相关配置 --
    USER_CLASS = 'gzone.models:Account'
    ADMIN_CLASS = 'gzone.models:Admin'
    ROOM_CLASS = 'gzone.models:Room'
    LOGIN_URL = '/gzone/login'

    # abs path to media folder
    # take precedence over MEDIA_FOLDER
    # MEDIA_ROOT = '/var/site/gzone/media'
    # MEDIA_FOLDER = 'media'
    # need end-slash
    # MEDIA_URL = '/media/'
    # 默认为False
    MOMENT_IMG_PRESERVE_ON_DELETE = True
    # 默认为False
    ALBUM_PHOTO_PRESERVE_ON_DELETE = True
    # 默认为False
    GROUP_FILE_PRESERVE_ON_DELETE = True
    # 默认为True
    # ALLOW_ADMIN_DELETION = True

    # 控制首页现实公告条数
    # 默认为3
    # INDEX_NOTICE_COUNT = 3
    # 默认是15
    MOMENT_PAGE_LENGTH = 1000
    # 如果设置为负值或否值,则无限制
    # 默认为300,单位秒
    MOMENT_DELETION_TIMEUP = -1
    # ALLOWED_UPLOAD_IMG_EXT = ('jpg', 'jpeg', 'png')
    # ALLOWED_UPLOAD_FILE_EXT = ('txt', 'pdf')
    # 默认为128x128
    # GZONE_IMG_THUMBNAIL_SIZE = (128, 128)

    # --- user loader config ---
    # default: True
    # OWNER_LOGIN_AS_ADMIN = True
    # default: one day
    # USER_INFO_EXPIRATION = 24 * 60 * 60

    # 当SKIP_OAUTH2为真时,会使得Anonymous类型的账户可以进入
    # 由于没有进行认证判断,
    # 某些操作会出现错误(需要绑定用户的操作)
    # 例如添加群友圈状态等
    # SKIP_OAUTH2 = False

    # Default: False
    # CAUTION: To use this flag, need some initial values
    # on db account table
    # and on redis related keys
    # or it may keep trying requesting oauth
    # NEEDS TO EXPIRE CLIENT'S SESSION AFTER CHANGING IT BACK TO FALSE
    # LOCAL_TEST = True

    # redis interface settings
    REDIS_HOST = 'zeroleo1234.chickenkiller.com'
    REDIS_PORT = 6666
    REDIS_PASSWORD = 'xiaobaizhushou'
    REDIS_DB = 1
    REDIS_SOCKET_TIMEOUT = None
    REDIS_SOCKET_CONNECT_TIMEOUT = 2

    GZONE = {
        'INDEX_SHOW_ANNOUNCEMENT_COUNT': 3,
    }


class LocalEnvConfig(DevelopmentConfig):
    # redis interface settings
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    REDIS_PASSWORD = None
    REDIS_DB = 1
    REDIS_SOCKET_TIMEOUT = None
    REDIS_SOCKET_CONNECT_TIMEOUT = 2

    LOCAL_TEST = True


config = {
    'development': DevelopmentConfig,
    'local': LocalEnvConfig
}
